<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/common/taglibs.jsp"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>菜单信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctxLayui}/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctxLayui}/layuiadmin/style/myStyle.css" media="all">
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 10px 0 0;">
    <div class="layui-form-item layui-form-item-my" >
        <label class="layui-form-label">父级</label>
        <div class="layui-input-block">
            <div id="parentId"></div>
            <input type="hidden" name="parentId" >
        </div>
    </div>
    <div class="layui-form-item layui-form-item-my" >
        <label class="layui-form-label">标题<span style="color:red">*</span></label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-form-item-my" >
        <label class="layui-form-label">路径</label>
        <div class="layui-input-block">
            <input type="text" name="path"  placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-item-my" >
        <label class="layui-form-label">按钮权限</label>
        <div class="layui-input-block">
            <input type="text" name="perms"  placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-item-my" >
        <label class="layui-form-label">排序<span style="color:red">*</span></label>
        <div class="layui-input-block">
            <input type="text" name="sortOrder" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-item-my" >
        <label class="layui-form-label">菜单类型<span style="color:red">*</span></label>
        <div class="layui-input-block">
            <select name="type" lay-verify="required" id="type" lay-filter="type">
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-form-item-my" >
        <label class="layui-form-label">图标</label>
        <div class="layui-input-block">
            <input type="text" name="icon" placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-item-my" >
        <label class="layui-form-label">状态<span style="color:red">*</span></label>
        <div class="layui-input-block">
            <select name="status" lay-verify="required" id="status" lay-filter="status">
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="添加">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="修改">
    </div>
</div>

<script src="${ctxLayui}/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '${ctxLayui}/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form','dict','xmSelect'], function(){

        var $ = layui.$
            ,form = layui.form;
        var admin = layui.admin;
        var dict = layui.dict;
        var xmSelect = layui.xmSelect;

        var formData = window.parent.formData;
        dict.setSelect("status","status",formData?(formData.status?formData.status:1):1);
        dict.setSelect("type","menuType",formData?(formData.type?formData.type:1):1);

        var parentXmSelect = xmSelect.render({
            el: '#parentId',
            prop:{name:'title',value:'id'},
            clickClose:true,
            radio:true,
            data: [],
            tree:{
                show:true,
                expandedKeys:true,
                strict:false,
            },
            on:function (data) {
                setTimeout(function () {
                    var valueStr = parentXmSelect.getValue("valueStr");
                    if(valueStr){
                        $("[name=parentId]").val(valueStr)
                    }
                },500)
            }
        });

        var rtn = admin.syncReq(ctx+'/system/sysMenu/sysMenuTreeList',{});
        var parentId = formData?formData.parentId:0
        parentXmSelect.update({
            data:rtn.data,
            autoRow:true,
            initValue:[parentId]
        });

        $("[name=parentId]").val(parentId)

    })
</script>
</body>
</html>